<?php include('scripts.php'); ?>
<script>
$(function() {
    $.populateDOB({
        dobYear : $("#dob_year")
        ,dobMonth : $("#dob_month")
        ,dobDay : $("#dob_day")
        ,dobFull : $("#dob")
        ,defaultValue : '<?php echo $distDB->getDob();?>'
    });

    $("#captchaimage").bind('click', function() {
        $.post('/captcha/newSession');
        $("#captchaimage").load('/captcha/imageRequest');
        return false;
    });

    $("#registerForm").validate({
        messages : {
            captcha: "<br><?php echo __('Correct captcha is required') ?>."
        },
        rules : {
            "captcha" : {
                required: true,
                remote: "/captcha/process"
            },
            "fullname" : {
                required : true,
                minlength : 2
            },
            "ic" : {
                required : true,
                minlength : 3
            },
            "address" : {
                required : true,
                minlength : 3
            },
            "postcode" : {
                required : true,
                minlength : 3
            },
            "email" : {
                required : true
                , email: true
            },
            "contactNumber" : {
                required : true
                , minlength : 10
            },
            "bankName" : {
                required : true
            },
            "bankAccountNo" : {
                required : true
            },
            "bankHolderName" : {
                required : true
            }
        },
        submitHandler: function(form) {
            waiting();
            form.submit();
        },
        success: function(label) {
            //label.addClass("valid").text("Valid captcha!")
        }
    });
});
</script>

<div style="padding: 10px; top: 30px; width: 98%">
    <div class="portlet">
        <div class="portlet-header"><?php echo __('View Profile') ?></div>
        <div class="portlet-content">
            <form id="registerForm" method="post" action="/member/updateProfile">
            <table cellpadding="0" cellspacing="5" border="0" width="100%">
                <tr>
                    <td colspan=2 align='center'>
                    <?php if ($sf_flash->has('successMsg')): ?>
                        <div class="ui-widget">
                            <div style="margin-top: 20px; padding: 0 .7em;" class="ui-state-highlight ui-corner-all">
                                <p><span style="float: left; margin-right: .3em;" class="ui-icon ui-icon-info"></span>
                                <strong><?php echo $sf_flash->get('successMsg') ?></strong></p>
                            </div>
                        </div>
                    <?php endif; ?>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table cellspacing="5" cellpadding="0">
                            <tr>
                                <td width="200px">
                                    <span id="Label4"><strong><?php echo __('Sponsor ID') ?></strong></span>
                                </td>
                                <td>
                                    <input name="sponsorId" readonly="readonly" id="sponsorId" tabindex="1" size="50"
                                           value="<?php echo $sponsor->getDistributorCode() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span id="Label25"><strong><?php echo __('Sponsor Name') ?></strong></span>
                                </td>
                                <td>
                                    <input name="sponsorName" readonly="readonly" id="sponsorName" tabindex="2" size="50"
                                           value="<?php echo $sponsor->getNickname() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span id="LabelNickName"><strong><?php echo __('Alias') ?></strong></span>
                                </td>
                                <td>
                                    <input name="nickName" type="text" id="nickName" tabindex="4" size="50"
                                           value="<?php echo $distDB->getNickname() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span id="Label13"><strong><?php echo __('Full Name') ?></strong></span>
                                </td>
                                <td>
                                    <input name="fullname" type="text" id="fullname" tabindex="5" size="50"
                                           value="<?php echo $distDB->getFullName() ?>"/>
                                </td>
                            </tr>

                            <tr>
                                <td class="login_t74">

                                    <span id="Label15"><strong><?php echo __('Passport/ID Card No.') ?></strong></span>
                                </td>
                                <td>
                                    <input name="ic" type="text" id="ic" tabindex="7" size="50"
                                           value="<?php echo $distDB->getIc() ?>"/></td>
                            </tr>

                            <tr>
                                <td class="login_t74">
                                    <span id="Label6"><strong><?php echo __('Country') ?></strong></span>
                                </td>
                                <td>
                                    <?php include_component('component', 'countrySelectOption', array('countrySelected' => $distDB->getCountry(), 'countryName' => 'country', 'countryId' => 'country')) ?>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span id="Label7"><strong><?php echo __('Address') ?></strong></span>
                                </td>
                                <td>
                                    <input name="address" type="text" id="address" tabindex="11" size="50"
                                           value="<?php echo $distDB->getAddress() ?>"/>
                                </td>

                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span id="Label17"><strong><?php echo __('Postal Code') ?></strong></span>
                                </td>
                                <td>
                                    <input name="postcode" type="text" id="postcode" tabindex="12" size="50"
                                           value="<?php echo $distDB->getPostcode() ?>"/>
                                </td>
                            </tr>
                            <tr class="login_t80">
                                <td class="login_t74" valign="top">
                                    <span id="Label18"><strong><?php echo __('Email') ?></strong></span>
                                </td>
                                <td>
                                    <input name="email" type="text" id="email" tabindex="13" size="50"
                                           value="<?php echo $distDB->getEmail() ?>"/>
                                </td>
                            </tr>
                            <tr class="login_t80">
                                <td class="login_t74" valign="top">

                                    <span id="Label19"><strong><?php echo __('Contact No.') ?></strong></span>
                                </td>
                                <td>
                                    <input name="contactNumber" type="text" id="contactNumber" tabindex="14" size="50"
                                           value="<?php echo $distDB->getContact() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74" style="padding-top: 5px;">
                                    <span id="Label14"><strong><?php echo __('Gender') ?></strong></span>
                                </td>

                                <td>
                                    <table id="RadioButtonListSex" border="0">
                                        <tr>
                                            <td><input id="rdoGender_0" type="radio" name="gender"
                                                       value="M" <?php if ($distDB->getGender() == "M") echo"checked='checked'"; ?> /><label
                                                    for="rdoGender_0"><strong><?php echo __('Male') ?></strong></label>
                                            </td>
                                            <td><input id="rdoGender_1" type="radio" name="gender"
                                                       value="F" <?php if ($distDB->getGender() == "F") echo "checked='checked'"; ?> /><label
                                                    for="rdoGender_1"><strong><?php echo __('Female') ?></strong></label>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span><strong><?php echo __('Date of Birth') ?></strong></span>
                                </td>
                                <td>
                                    <select id="dob_year"></select>
                                    <select id="dob_month"></select>
                                    <select id="dob_day"></select>
                                    <input name="dob" readonly="readonly" type="hidden" id="dob" class="bp_05"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span><strong><?php echo __('Bank Name') ?></strong></span>
                                </td>
                                <td>
                                    <input name="bankName" type="text" id="bankName" tabindex="16" size="50"
                                           value="<?php echo $distDB->getBankName() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span><strong><?php echo __('Bank Holder Name') ?></strong></span>
                                </td>
                                <td>
                                    <input name="bankHolder" type="text" id="bankHolder" tabindex="17" size="50"
                                           value="<?php echo $distDB->getBankHolderName() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <span><strong><?php echo __('Bank Account No.') ?></strong></span>
                                </td>
                                <td>
                                    <input name="bankNo" type="text" id="bankNo" tabindex="18" size="50"
                                           value="<?php echo $distDB->getBankAccNo() ?>"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="login_t74">
                                    <div id="captchaimage" style="height: 32; width: 100">
                                        <a href="<?php echo $_SERVER['PHP_SELF']; ?>" id="refreshimg" title="Click to refresh image"><img src="/captcha/image?<?php echo time(); ?>" width="90" height="30" alt="Captcha image" style="border-style: none"/></a>
                                    </div>
                                </td>
                                <td>
                                    <input name="captcha" type="text" id="captcha" class="login_t73" size="10" tabindex="19"/>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td><hr></td>
                </tr>
                <tr>
                    <td>
                        <button id="btnUpdate"><?php echo __('Update') ?></button>
                    </td>
                </tr>
            </table>
            </form>
        </div>
    </div>
</div>